CodeToObj is a tool that takes the contents of any resource, and turns it into a 68K object code file. This can be useful, for example, for building a block of code that is made memory-resident by other code, but which cannot, for some reason, be stored in a separate code resource (perhaps because the loader code itself takes the form of a non-application code resource!). The resident code must have its own copy of any library code; to ensure this, build it into a temporary code resource with a separate Link operation, then you can include the contents of that resource in the rest of your program with the help of CodeToObj.
Use this tool in an MPW command as follows:
CodeToObj ResFile ResType ResID OutputFile
where ResFile is the name of the file containing the resource, ResType is the resource type (which may be specified as either 4 literal characters or 8 hex digits), ResID is the integer resource ID, and OutputFile is the name of the object file to create.
Options may be specified anywhere on the command line. The following ones are required:
-start StartSym
gives a symbol name to the start of the code.
-end EndSym
gives a symbol name to the point immediately after the last byte of the code.
The following options may additionally be specified:
-segment SegmentName
gives a name to the segment containing the generated code. If omitted, the default is the usual “Main”.
-entry EntrySym1[,EntrySym2...]
gives symbol names to one or more entry points within the code (note that there must not be any spaces before or after the commas). If this option is specified, then the resource contents are assumed to begin with a series of longwords, one for each entry point name in sequence, containing the offset from the beginning of the resource to the corresponding entry point. These prefix longwords are stripped off from the generated code.
This reads the PROC resource with ID 128 from the file MyRes, and puts its contents into an object file with name MyResObj.o. The start of the contents is given the name CodeStart, and the end is named CodeEnd.